package cn.sso.app.client.api.server;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.ifloat.brick.basic.common.results.PageRequester;
import cn.ifloat.brick.basic.common.results.PageRequesterFormCondition;
import cn.ifloat.brick.basic.common.results.PageResult;
import cn.sso.app.client.api.ProjectApi;
import cn.sso.app.client.example.domain.Project;
import cn.sso.app.client.example.services.ProjectService;
import cn.sso.app.client.example.vo.ProjectVo;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

/**
 * @author: float 2023/1/17 11:13
 * 项目实现
 */
@RestController
public class ProjectServer implements ProjectApi {

    @Autowired
    private ProjectService projectService;

    @Override
    @SaIgnore
    public PageResult<Project> pager(PageRequester<Project> requester) {
        return projectService.pager(requester);
    }

    @Override
    @SaIgnore
    public PageResult<ProjectVo> pagerVo(PageRequester<ProjectVo> requester) {
        return projectService.pagerVo(requester);
    }

    @Override
    @SaIgnore
    public PageResult<Project> pagerCondition(PageRequesterFormCondition<Project> requester) {
        return projectService.pager(Project.class, requester);
    }

    @Override
    @SaIgnore
    public ProjectVo get(Long id) {
        return projectService.getById(id);
    }

    @Override
    @SaIgnore
    public List<Project> list(Project project) {

        Wrapper<Project> wrapper = projectService.builder(project);
        return projectService.list(wrapper);
    }

    @Override
    @SaIgnore
    public List<ProjectVo> listVo(ProjectVo vo) {
        Wrapper<ProjectVo> wrapper = projectService.builderByVo(vo);
        return projectService.listVo(vo);
    }

    @Override
    @SaIgnore
    public void save(ProjectVo vo) {
        projectService.saver(vo);
    }

    @Override
    @SaIgnore
    public void update(ProjectVo vo) {
        projectService.saverOrUpdater(vo);
    }

    @Override
    @SaIgnore
    public void updateAll(ProjectVo vo) {
        projectService.updateById(vo);
    }

}
